// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

import ElementUI from 'element-ui'

import './assets/theme/index.css'
import '@/assets/fonts/iconfont/iconfont.css'
import { os } from '@/libs/util'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import _ from 'lodash'
import '@/assets/style/common.scss'
import VueContextMenu from 'vue-contextmenu'
import { request1 } from './network/request'
import echarts from 'echarts'
import App from './App'
import router from './router'
import store from './store'
import './permission'
//引入echarts
import htmlToPdf from '@/util/htmlToPdf'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use(Viewer)
Viewer.setDefaults({
  Options: {
    inline: true,
    button: false,
    navbar: true,
    title: true,
    toolbar: true,
    tooltip: true,
    movable: true,
    zoomable: true,
    rotatable: true,
    scalable: true,
    transition: true,
    fullscreen: true,
    keyboard: true,
    url: 'data-source'
  }
})
// 使用Vue.use()方法就会调用工具方法中的install方法
Vue.use(htmlToPdf)

Vue.use(ElementUI)

Vue.use(VueContextMenu)

library.add(faCoffee)

Vue.component('font-awesome-icon', FontAwesomeIcon)

Vue.config.productionTip = false
//引入echarts
Vue.prototype.$echarts = echarts

Vue.prototype.$axios = request1
/* eslint-disable no-new */

//全局阻止页面滑动效果
//弹出框禁止滑动
Vue.component('remote-script', {

  render: function (createElement) {
    var self = this
    return createElement('script', {
      attrs: {
        type: 'text/javascript',
        src: this.src
      },
      on: {
        load: function (event) {
          self.$emit('load', event)
        },
        error: function (event) {
          self.$emit('error', event)
        },
        readystatechange: function (event) {
          if (this.readyState === 'complete') {
            self.$emit('load', event)
          }
        }
      }
    })
  },

  props: {
    src: {
      type: String,
      required: true
    }
  }
})
Vue.prototype.stopScroll = function () {
  var mo = function (e) { e.preventDefault() }
  document.body.style.overflow = 'hidden'
  document.addEventListener('touchmove', mo, false)// 禁止页面滑动
}
//弹出框可以滑动
Vue.prototype.canScroll = function () {
  var mo = function (e) {
    e.preventDefault()
  }
  document.body.style.overflow = ''// 出现滚动条
  document.removeEventListener('touchmove', mo, false)
}
Vue.directive('dialogDrag', {
  bind(el, binding, vnode) {
    // console.log(el);
  }
})
//当需要禁止弹出框底部内容滑动时调用：
// this.stopScroll()
//当需要页面恢复滑动功能时调用：
//this.canScroll()
import MainFooter from '@/components/common/MainFooter'
import MainHeader from '@/components/common/MainHeader'
import Commontitle from '@/components/common/title'
Vue.component('MainFooter', MainFooter)
Vue.component('MainHeader', MainHeader)
Vue.component('Commontitle', Commontitle)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
